#coding=utf-8

import os
import logging
import wsgiref.handlers
import tornado.wsgi

from app.controllers import *

LOGGING_LEVEL = logging.WARN

settings = {
    "blog_title": u"Rockmaple's Blog",
    "template_path": os.path.join(os.path.dirname(__file__), "templates"),
    "ui_modules": {"Entry":    EntryModule, 
                   "TagCloud": TagCloudModule},
    "xsrf_cookies": True,
}

url_mappings = [
    (r"/",                       HomeController),
    (r"/entries/([0-9]+)",       EntryController),
    (r"/removeentry/([0-9]+)",   RemoveEntryController),
    (r"/compose",                ComposeController),
    (r"/tags",                   TagsController),
    (r"/tags/([^/]+)/entries",   TagEntriesController),
    (r"/archive",                ArchiveController),
    (r"/atom.xml",               AtomController),
]

application = tornado.wsgi.WSGIApplication(url_mappings, **settings)

def main():
    logging.getLogger().setLevel(LOGGING_LEVEL)
    wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
    main()